﻿namespace DL.CfgData
{
    public abstract class TextCfgData : ITextCfgData
    {
        public abstract string ConfigFileName { get; }

        protected string CfgDataContent { get; private set; }

        public void LoadConfig(string cfgDataContent)
        {
            if (cfgDataContent != null && this.CfgDataContent == cfgDataContent)
                return;
            this.CfgDataContent = cfgDataContent;
            this.Load(this.CfgDataContent);
        }

        public virtual bool IsRelativeToFile(string fileName) =>
            this.ConfigFileName != null && this.ConfigFileName == fileName;

        protected abstract void Load(string cfgDataContent);
    }
}